Repository navigation
Add a command to send requests to hosted endpoints - #29
Merged
Merged
Conversation
`adapt endpoints request ID [PATH]` looks up the endpoint's URL, sends one request to the hosted application, and streams the response body to stdout. It supports -X, -H, -d, an explicit --token, or --new-token to create one. Platform credentials only look up the endpoint and create a token. The application receives the caller's headers and, at most, the endpoint token in X-Adapt-Authorization. Redirects are not followed. A non-2xx status prints the body, then exits 1. Closes #4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Confidence Score: 4/5
Summary
Adds streamed endpoint requests with isolated endpoint authentication and cancellable body input. Code risk appears low after local formatting, clippy, 112 tests, and loopback probes; live application integration and non-Linux execution remain unverified.
Deployed verification not applicable: adapt/platform-cli is outside the adapt/adapt and adapt/platform preview pilot; no webhook was sent.
Important Files Changed
| File | Changes |
|---|---|
| src/commands.rs | Endpoint resolution, isolated requests, token creation, streaming, diagnostic redaction, and interruptible body reads. |
| src/cli.rs | Endpoint request arguments and deferred header validation to avoid credential echoes. |
| src/input.rs | Shared byte-input helper and sanitized application-header validation. |
| src/main.rs | Endpoint-specific Ctrl-C messaging. |
| tests/endpoint_request/mod.rs | Streaming, authentication, redirects, binary bodies, input errors, diagnostic privacy, and cancellation regression coverage. |
| tests/cli.rs | Registers endpoint request integration tests. |
| docs/cli-reference.md | Documents endpoint requests, authentication, streaming, timeouts, cancellation, and exit behavior. |
| skills/adapt/SKILL.md | Adds endpoint request examples and credential-isolation guidance. |
Run info
| Field | ID |
|---|---|
| Agent | 0d6ccd7e-b62f-4075-a561-199d1a7b1bf0 |
| Automation | ec14e69d-634f-4af0-a6dd-27aa06a1f6b3 |
| Run | 07d727f5-b6b3-4978-b6c6-e4da48d2d783 |
Reviewed: ce8604b-cbc9332 · ↻ Re-run review
- Parse -H in the command instead of clap, whose errors repeat the rejected value. A forbidden X-Adapt-Authorization header or a malformed header no longer prints a credential; these now exit 1. - Strip request URLs from transport and body errors with without_url(), as Api does, so a credential in the query is never printed. - Read a `-d -` body and write the response with tokio's async stdin and stdout, so Ctrl-C exits 130 while waiting for input or a full stdout pipe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read -d bodies on a blocking worker for all sources, not only stdin. An @file path can also block on a FIFO or device; runtime shutdown does not wait for the worker, so Ctrl-C still exits 130 while opening or reading. Tests cover byte-exact bodies from -, @-, a file and /dev/stdin, missing and oversized files, and Ctrl-C during @-, /dev/stdin and FIFO open/read. The Ctrl-C helper now reaps the child it kills on timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4
Summary
adapt endpoints request ID [PATH]looks up the endpoint's URL, sends one request to the hosted application, and writes the response body to stdout as it arrives. SSE streams work with no special handling.-Xsets the method,-H "Name: value"adds application headers (repeatable), and-dsends a body (inline,@file, or-for stdin). These letters match curl's.--token TOKENuses an existing endpoint token.--new-tokencreates one throughPOST /v1/ingresses/{id}/access-tokensfor the resolved ID (not the prefix) and uses it. The two flags conflict./, may include a query, and is appended to the endpoint URL the way the guide builds${ENDPOINT_URL}events. A path with a host,//,\or#is refused before any request is sent.Location.-dbody is read from stdin, a device or a FIFO (on a blocking worker the runtime doesn't wait for), and while stdout is blocked (tokio's async stdout).Credential isolation
Api::request(), so it never carries the PlatformAuthorizationorX-Organization-Id. Platform credentials are used only for the endpoint lookup and token creation.X-Adapt-Authorization, marked sensitive.-Hcan't set that header. AnAuthorizationheader passed with-Hreaches the application unchanged.-His parsed by the command rather than clap, so an error never repeats a rejected header value, which could be a credential. Transport and body errors omit the request URL, which could carry one in its query.ensure_success, so an app's 401 isn't reported as "runadapt auth login".Changes beyond endpoints request
input::datareads inline,@fileor stdin bytes.input::jsonnow uses it.endpoints requestexits 130 without printing "Remote executions continue…", since nothing remote is left running.Docs
docs/cli-reference.mdgets an Endpoint requests section with equivalents for the three curl examples in the published Endpoints guide, and lists the command in the table. The bundled skill is updated.Testing
tests/endpoint_request/mod.rshas 13 tests against a mock Platform and a separate mock application:Content-Length: the first event must reach stdout while the application holds the stream open. When I made the code buffer the whole body, this test failed in about 10 seconds instead of hanging.--new-tokenwith an ID prefix, a POST body, and an applicationAuthorizationheader. Then--tokenagainst an endpoint URL with a path prefix. Every application request is checked for the absence of Platform credentials.Locationis reported.X-Adapt-Authorizationheader, a malformed header, and--tokenwith--new-token.-,@-, a file and@/dev/stdinarrive byte for byte (including NUL and invalid UTF-8) with no addedContent-Type. A missing file and one over 16 MiB are reported, and the application request is never sent.-,@-,@/dev/stdin, or a FIFO (both while opening it and while reading it), and while stdout is full. With blocking I/O on the async thread, the stdin and stdout tests failed instead of hanging.INGRESS_DOMAIN=sandbox.test:--new-tokensucceeded with an API key, and the CLI builthttps://ID.sandbox.test/events?since=1. The final request stopped at DNS, since that domain has no DNS or TLS locally.Hostheader): no token or a wrong token got 401, and a token fromadapt endpoints tokenpassed the auth check and reached404 Endpoint is not bound.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo test --lockedpass.Known limits
--timeout(default 60s) ends with exit 1. Platform's proxy also closes SSE streams after 60 seconds of inactivity.adapt/platformisn't edited here. Its source wasn't accessible to me, so its curl examples can be switched to these commands in the docs PR.🤖 Generated with Claude Code